home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 4 / Precision Software Applications Silver Collection Volume 4 (1993).iso / stats / chadyn.exe / YXPLOT.C < prev    next >
C/C++ Source or Header  |  1988-12-08  |  21KB  |  676 lines

  1. /* YXPLOT.C - routines to perform the same services as those in YPLOT.C
  2.  * but using the X windows library.
  3.  * Notes on this version:
  4.  * 1.  no "core" copy of the picture is retained.
  5.  * 2.  there is no printer support yet.
  6.  * Programmer:  Eric Kostelich, Institute for Physical Science and Technology,
  7.  *        University of Maryland, College Park  20742
  8.  */
  9. #define XINCLUDES
  10. #include "yinclud.h"
  11. #ifdef X11
  12.  
  13. /* ---------------------------------------------------------------------- */
  14. /* BOOTCRT - redraws the screen according to the value of the gloval
  15.  * variable "boot".  If boot == 0, then we clear the screen and allocate
  16.  * a "core" copy of the graphics screen.  Otherwise, we do nothing.
  17.  * Note:  this is a temporary version.
  18.  */
  19. boot_crt()
  20. {
  21. #ifdef NEW
  22.     XImage    *coreimage;
  23. #endif    /* NEW */
  24.     int    i;
  25.  
  26.     ScreenConstants();    /* to fix up some constants */
  27.     IsCross0Set = NO;    /* screen cross at y0 is not set */
  28.     IsCross1Set = NO;    /* screen cross at yval is not set */
  29.     if(printer == 3)
  30.         bottomPrint();
  31. #ifdef NEW
  32.     XClearWindow(x_dpy, x_window);
  33.     if(boot == 0)  {     /* allocate core copy and clear it */
  34.         if(x_core == (Pixmap) 0 &&
  35.            (x_core = XCreatePixmap(x_dpy, x_window, scrncols, 
  36.                scrnrows, 1)) == (Pixmap) 0)
  37.                die("can't create core copy of graphics");
  38.         XFillRectangle(x_dpy, x_core, x_gcblank, 0, 0,
  39.             (unsigned) scrncols, (unsigned) scrnrows);
  40.         if(ScrnSec == 0)    /* turn off window overlap prevention */
  41.             for(i = 0; i <= 4; i++)
  42.                 windowflag[i] = OFF;
  43.     } 
  44.     else {            /* copy core image to screen */
  45.         coreimage = XGetImage(x_dpy, x_core, 0, 0, scrncols, scrnrows,
  46.             AllPlanes, XYPixmap);
  47.         XPutImage(x_dpy, x_window, x_gc, coreimage, 0, 0, 0, 0, 
  48.             scrncols, scrnrows);
  49.         XDestroyImage(coreimage);    /* to conserve memory */
  50.     }
  51. #else            /* temporary version */
  52.     if(boot == 0)  {
  53.         XClearWindow(x_dpy, x_window);
  54.         if(ScrnSec == 0)    /* turn off window overlap prevention */
  55.             for(i = 0; i <= 4; i++)
  56.                 windowflag[i] = OFF;
  57.     }
  58. #endif    /* NEW */
  59.     if(boxx)     /* draw a box if requested */
  60.         draw_box();
  61.     boot = 0;
  62.     return;
  63. }
  64. /* ---------------------------------------------------------------------- */
  65. ScreenConstants()
  66. {
  67.     X_Lo[ScrnSec] = X_lower;
  68.     X_Up[ScrnSec] = X_upper;
  69.     Y_Lo[ScrnSec] = Y_lower;
  70.     Y_Up[ScrnSec] = Y_upper;
  71.     xScrPix[ScrnSec] = scrncols / (X_upper - X_lower);/* for screen   */
  72.     yScrPix[ScrnSec] = scrnrows / (Y_upper - Y_lower);
  73.     return;
  74. }
  75. /* ---------------------------------------------------------------------- */
  76. /* FINDPIXEL - return a pointer to a POINT (integer point) which maps the
  77.  * floating point (x,y) to integer screen coordinates.
  78.  * Return NULL if (x,y) would fall outside the screen area.
  79.  * However, forgive a 1-pixel overflow.
  80.  * Note:  this is a temporary version which returns NULL unless PICNUM
  81.  * refers to the screen.
  82.  */
  83. POINT    *FindPixel(xval, yval, picnum)
  84. double  xval, yval;
  85. int     picnum;
  86. {
  87.     static POINT    scrnpt;
  88.     int    xmax, ymax;
  89.  
  90.     if(picnum == 1) {    /* crt */
  91.         xmax = scrncols;
  92.         ymax = scrnrows;
  93.         scrnpt.x = xScrPix[ScrnSec] * (xval - X_lower);
  94.         if(scrnpt.x == xmax)
  95.             scrnpt.x--;
  96.         scrnpt.y = yScrPix[ScrnSec] * (Y_upper - yval);
  97.         if(scrnpt.y == ymax)
  98.             scrnpt.y--;
  99.     }
  100.     else
  101.         return(NULL);
  102.  
  103.     if(scrnpt.x >= 0 && scrnpt.x < xmax && scrnpt.y >= 0
  104.        && scrnpt.y < ymax)  {
  105.         switch(ScrnSec)  {
  106.         case UPPERLEFT:
  107.             scrnpt.x /= 2;
  108.             scrnpt.y /= 2;
  109.             break;
  110.         case UPPERRIGHT:
  111.             scrnpt.x = (scrnpt.x + xmax) / 2;
  112.             scrnpt.y /= 2;
  113.             break;
  114.         case LOWERLEFT:
  115.             scrnpt.x = scrnpt.x / 2;
  116.             scrnpt.y = (scrnpt.y + ymax) / 2;
  117.             break;
  118.         case LOWERRIGHT:
  119.             scrnpt.x = (scrnpt.x + xmax) / 2;
  120.             scrnpt.y = (scrnpt.y + ymax) / 2;
  121.             break;
  122.         }
  123.         return(&scrnpt);
  124.     }
  125.     else
  126.         return(NULL);
  127. }
  128. /* -------------------------------------------------------------------- */
  129. /* PLOT - maps the point (xval, yval) in user coordinates to screen coordinates
  130.  * and plots the dot if it is within the screen boundaries.  Otherwise
  131.  * it checks whether the point is too far away and sets single step mode
  132.  * as needed.
  133.  */
  134. plot(xval, yval)
  135. double  xval, yval;
  136. {
  137.     POINT    *p;
  138.  
  139.     /* If we are outside the screen, then check that we're not
  140.      * so far away that we need to go to single step mode to
  141.      * prevent overflow.
  142.      */
  143.     if((p = FindPixel(xval, yval, SCRN)) == NULL)
  144.         checkiterate(xval, yval);
  145.     else {
  146.         /* If the cross is not turned off, and the new dot to be plotted
  147.          * is in the cross, it will cause erased when the cross goes.
  148.          */
  149.         if(IsCross0Set)
  150.             turnoff(BIGCROSS);
  151.         setPixel(p);
  152.         if(cross0flag)        /* set using interrupt 'k' */
  153.             SetCross(BIGCROSS);
  154.     }
  155.     return;
  156. }
  157. /* -------------------------------------------------------------------- */
  158. /* CHECKITERATE - Check whether a point, which is not in the window,
  159.  * is within "diameters[ScrnSec]" times the width and within 
  160.  * "diameters[ScrnSec] times the height of the
  161.  * screen. If it is not close enough to the screen based on this
  162.  * criterion, the program is reset to SINGLE STEP mode to prevent
  163.  * overflow.
  164.  * Note: the check is done only if the value of DIAMETERS is > 0.
  165.  */
  166. checkiterate(xval, yval)
  167. double    xval, yval;
  168. {
  169.     double    d, xdif, ydif;
  170.  
  171.     if((d = diameters[ScrnSec]) > 0.0)  {
  172.         xdif = X_upper - X_lower;
  173.         ydif = Y_upper - Y_lower;
  174.         d *= (d + 1.0);
  175.         if((X_upper - xval) * (xval - X_lower) > d * xdif * xdif
  176.             || (Y_upper - yval) * (Y_lower - yval) > d * ydif * ydif)
  177.             PlotComplaint(xval, yval);
  178.     }
  179.     return;
  180. }
  181. /* -------------------------------------------------------------------- */
  182. /* PLOTCOMPLAINT - complain about points too far away.
  183.  */
  184. PlotComplaint(xval, yval)
  185. double    xval, yval;
  186. {
  187. #ifndef MAINFRAME
  188.     scr_rowcol(1, 0);
  189.     PRINT
  190.         "X = %.12g   Y = %.12g  \n", xval, yval);
  191.     PRINT
  192.         "This point is too far from screen: more than %g diameters from the screen\n",
  193.         diameters[ScrnSec]);
  194.     PRINT
  195.         "Program now enters SINGLE STEP mode to prevent overflow\n");
  196.     PRINT
  197.         "Reinitialize using 'i' or 'm' or cursor keys and/or reset menu's parameters\n"
  198.         );
  199.     PRINT
  200.         "\nTo change 'diameters', return to menu(hit space bar) and enter P then SD\n"
  201.         );
  202. #endif    /* MAINFRAME */
  203.     cycle = 2;        /* single step mode; setting cycle = 2 tells
  204.                    Interrupt() not to call plot() since that
  205.                    would give an infinite loop */
  206.     Interrupt();
  207.     return;
  208. }
  209. /* -------------------------------------------------------------------- */
  210. /* CLRWINDOW - clear a section of the window. */
  211. clrWindow() 
  212. {
  213.     stoplines();         /* for stopping drawing connected lines */
  214.     SignIsOn = 0;        /* sign about jump size */
  215.     IsCross0Set = NO;    /* screen cross at y0 is not set */
  216.     IsCross1Set = NO;    /* screen cross at y1 is not set */
  217.     turnoff(BIGCROSS);
  218.     turnoff(SMALLCROSS);
  219.     if(ScrnSec == 0) {
  220.         scr_clr();
  221.     }
  222.     else if(ScrnSec == 1) {
  223.         picOff(0, 0, corecols / 2, corerows / 2);
  224.         scrOff(0, 0, scrncols / 2, scrnrows / 2);
  225.     }
  226.     else if(ScrnSec == 2) {
  227.         picOff(corecols / 2, 0, corecols, corerows / 2);
  228.         scrOff(scrncols / 2, 0, scrncols, scrnrows / 2);
  229.     }
  230.     else if(ScrnSec == 3) {
  231.         picOff(0, corerows / 2, corecols / 2, corerows);
  232.         scrOff(0, scrnrows / 2, scrncols / 2, scrnrows);
  233.     }
  234.     else if(ScrnSec == 4) {
  235.         picOff(corecols / 2, corerows / 2, corecols, corerows);
  236.         scrOff(scrncols / 2, scrnrows / 2, scrncols, scrnrows);
  237.     }
  238.     return;
  239. }
  240. /* -------------------------------------------------------------------- */
  241. /* TICGAP - return distance between tic marks; input difference between left
  242.  * and right scales; returns a number starting with a digit 5,6,7,8, or 9;
  243.  * Hence .0056... returns .005, and -.0056 becomes -.005; if first digit
  244.  * is 1, number is multiplied by 5; if first digit is less than 5, number
  245.  * is multiplied by 2.
  246.  */
  247. double  ticGap(dif)        
  248. double  dif;
  249. {
  250.     double  old = dif;    /* keeps track of change in size of dif */
  251.  
  252.     if(dif == 0.0)
  253.         return(0.0);
  254.     if(dif < 0.0)
  255.         dif = -dif;
  256.     while(dif < 1.0)
  257.         dif *= 10.0;
  258.     while(dif > 10)
  259.         dif /= 10.0;
  260.     if(dif < 2.0)
  261.         dif *= 5.0;
  262.     if(dif < 5.0)
  263.         dif *= 2.0;
  264.     return(old / dif);
  265. }
  266. /* -------------------------------------------------------------------- */
  267. /* TICMARKS - draw the tick marks.  FLAG == 2 means that an extra fine
  268.  * set of tic marks should be drawn with 1/5 the spacing.  This extra set
  269.  * is small and will show up better when  the picture is printed.
  270.  */
  271. ticMarks(flag)
  272. int     flag;
  273. {
  274.     int     size, j, ntic, ticlen;        /* TICLEN is in pixels */
  275.     double  gap, x, v;
  276.     POINT    *p;
  277.     XSegment    *ticlist, *tp;        /* indexes ticlist */
  278.  
  279.     scr_rowcol(2, 0);
  280.     size = (flag == 2 ? 170 : 100);
  281.  
  282.     if((gap = ticGap(X_upp - X_low)) == 0.0)  {
  283.         PRINT "CANNOT DRAW TIC MARKS; BOX HAS 0 WIDTH      \n");
  284.         return;
  285.     }
  286.     if(flag == 2)
  287.         gap /= 5.0;
  288.  
  289.     /* moduloAB() is a number between 0 and GAP -- even if GAP 
  290.      * is negative.
  291.      */
  292.     x = X_low - moduloAB(X_low, 0.0, gap) + gap;
  293.     x += gap * 0.000001;
  294.     erase_line();
  295.     PRINT "Horizontal spacing between tic marks: %g starting at %g\n",
  296.         gap, x);
  297.     ntic = (int) (fabs(X_upp - x) / fabs(gap));
  298.     tp = ticlist 
  299.        = (XSegment *) malloc((unsigned) ntic * 2 * sizeof(XSegment));
  300.     ticlen = scrnrows / size;
  301.  
  302.     /* Store tics as small segments which we plot in one call.
  303.      * First do the ones along the bottom axis.
  304.      */
  305.     for(j = 0; j < ntic; j++)  {
  306.         if((p = FindPixel(x + j * gap, Y_low, SCRN)) != NULL)  {
  307.             tp->x1 = tp->x2 = p->x;
  308.             tp->y1 = p->y;
  309.             tp->y2 = p->y - ticlen;
  310.             tp++;
  311.         }
  312.     }
  313.     /* Now do the ones along the top */
  314.  
  315.     for(j = 0; j < ntic; j++)  {
  316.         if((p = FindPixel(x + j * gap, Y_upp, SCRN)) != NULL)  {
  317.             tp->x1 = tp->x2 = p->x;
  318.             tp->y1 = p->y;
  319.             tp->y2 = p->y + ticlen;
  320.             tp++;
  321.         }
  322.     }
  323.     /* Display the tick marks along the X direction.  */
  324.  
  325.     XDrawSegments(x_dpy, x_window, x_gc, ticlist, (int) (tp - ticlist));
  326.  
  327.     /* Repeat for the tick marks along the Y axis */
  328.  
  329.     if((gap = ticGap(Y_upp - Y_low)) == 0.0)  {
  330.         PRINT "CANNOT DRAW TIC MARKS; BOX HAS 0 HEIGHT            \n");
  331.         return;
  332.     }
  333.     if(flag == 2)
  334.         gap /= 5.0;
  335.     v = Y_low - moduloAB(Y_low, 0., gap) + gap;
  336.     v = v + gap * 0.000001;
  337.     PRINT "Vertical spacing between tic marks: %g starting at %g\n",
  338.         gap, v);
  339.  
  340.     j = (int) (fabs(Y_upp - v) / fabs(gap));
  341.     if(j > ntic)  {
  342.         ntic = j;
  343.         ticlist = (XSegment *) realloc((char *) ticlist, 
  344.             (unsigned) ntic * 2 * sizeof(XSegment));
  345.     }
  346.     /* Now do the tick marks on the right */
  347.  
  348.     tp = ticlist;
  349.     for(j = 0; j < ntic; j++)  {
  350.         if((p = FindPixel(X_upp, v + j * gap, SCRN)) != NULL)  {
  351.             tp->y2 = tp->y1 = p->y;
  352.             tp->x1 = p->x;
  353.             tp->x2 = p->x - ticlen;
  354.             tp++;
  355.         }
  356.     }
  357.     /* Now do the tick marks on the left */
  358.  
  359.     for(j = 0; j < ntic; j++)  {
  360.         if((p = FindPixel(X_low, v + j * gap, SCRN)) != NULL)  {
  361.             tp->y2 = tp->y1 = p->y;
  362.             tp->x1 = p->x;
  363.             tp->x2 = p->x + ticlen;
  364.             tp++;
  365.         }
  366.     }
  367.     /* Display the tick marks along the Y direction.  */
  368.  
  369.     XDrawSegments(x_dpy, x_window, x_gc, ticlist, (int) (tp - ticlist));
  370.  
  371.     free((char *) ticlist);
  372.     return;
  373. }
  374. /* -------------------------------------------------------------------- */
  375. /* CONNECT2 - connect (xval, yval) to (xval2, yval2).
  376.  */
  377. connect2(xval, yval, xval2, yval2)
  378. double  xval, yval, xval2, yval2;
  379. {
  380.     POINT    from, *p;
  381.  
  382.     /* Erase big cross temporarily so we store contents of line if
  383.      * the line intersects the region obscured by the box circumscribing
  384.      * the cross.
  385.      */
  386.     if(cross0flag)
  387.         turnoff(BIGCROSS);
  388.     if((p = FindPixel(xval, yval, SCRN)) != NULL)  {
  389.         from = *p;
  390.         if((p = FindPixel(xval2, yval2, SCRN)) != NULL)
  391.             XDrawLine(x_dpy, x_window, x_gc, from.x, from.y, p->x,
  392.                 p->y);
  393.         else
  394.             checkiterate(xval2, yval2);
  395.     } else
  396.         checkiterate(xval, yval);
  397.  
  398.     if(cross0flag)        /* turn the big cross back on again */
  399.         SetCross(BIGCROSS);
  400.     stoplines();         /* for stopping drawing connected lines */
  401.     return;
  402. }
  403. /* -------------------------------------------------------------------- */
  404. /* CONNECTP - connect (x,y) to the previously drawn point.  The screen 
  405.  * coordinates of the previously drawn point are pointed to by STARTPT.
  406.  * If STARTPT is NULL, then line drawing has been turned off, so we
  407.  * do nothing.
  408.  */
  409. connectp(xval, yval)
  410. double  xval, yval;
  411. {
  412.     static POINT    lastpt;        /* endpoint of last segment drawn */
  413.     POINT    *p;
  414.  
  415.     /* If the point is out of bounds, check that it is not so far
  416.      * away that we're about to blow up.
  417.      */
  418.     if((p = FindPixel(xval, yval, SCRN)) == NULL)    {
  419.         checkiterate(xval, yval);
  420.         stoplines();     /* for stopping drawing connected lines */
  421.     }
  422.     /* In case we just did a modulo operation, or if line drawing has
  423.      * been turned off, then don't plot any lines.
  424.      */
  425.     else {
  426.         if(startpt != NULL && modFlag == NO)
  427.             XDrawLine(x_dpy, x_window, x_gc, startpt->x,
  428.                 startpt->y, p->x, p->y);
  429.         lastpt = *p;
  430.         startpt = &lastpt;    /* prime the pump */
  431.     }
  432.     return;
  433. }
  434. /* -------------------------------------------------------------------- */
  435. /* SCROFF - blank out the indicated region in screen coordinates */
  436. scrOff(COLnum1, ROWnum1, COLnum2, ROWnum2)
  437. int     COLnum1, ROWnum1, COLnum2, ROWnum2;
  438. {
  439.     int     width = COLnum2 - COLnum1;
  440.     int    height = ROWnum2 - ROWnum1;
  441.  
  442.     if(width > 0 && height > 0)
  443.         XFillRectangle(x_dpy, x_window, x_gcblank, COLnum1, ROWnum1,
  444.             (unsigned) width, (unsigned) height);
  445.     return;
  446. }
  447. /* -------------------------------------------------------------------- */
  448. /* PICOFF - blank out the indicated region in the core copy of the picture */
  449. /* Note:  this is a no-op for now. */
  450. picOff(COLnum1, ROWnum1, COLnum2, ROWnum2) 
  451. {
  452.     return;
  453. }
  454. /* -------------------------------------------------------------------- */
  455. /* BLOCK_PLOT - fill the rectangle whose corner points are given by
  456.  * (xval, yval) and (xval2, yval2).  Both points MUST be visible on the screen;
  457.  * otherwise no rectangle is drawn.
  458.  */
  459. block_plot(xval, xval2, yval, yval2)
  460. double   xval, xval2, yval, yval2;
  461. {
  462.     POINT    *p, from;
  463.     int    width, height;
  464.  
  465.     if((p = FindPixel(xval, yval, SCRN)) != NULL)  {
  466.         from = *p;
  467.         if((p = FindPixel(xval2, yval2, SCRN)) != NULL)  {
  468.             width = p->x - from.x;
  469.             height = p->y - from.y;
  470.             XFillRectangle(x_dpy, x_window, x_gc, from.x, from.y,
  471.                 (unsigned) width, (unsigned) height);
  472.         }
  473.     }
  474.     return;
  475. }
  476. /* -------------------------------------------------------------------- */
  477. /* BOTTOMPRINT - print list of interrupts. */
  478. bottomPrint() 
  479. {
  480. #ifndef MAINFRAME
  481.     scr_rowcol(21, 0);    /* move cursor to bottom left; */
  482.  
  483.     PRINT
  484.         "Type * for detailed help.        \n");
  485.     PRINT
  486.         "Type ? for description of INTERRUPTS; hit 2 to reduce unnecessary printing \n"
  487.         );
  488.     PRINT
  489.         "KEYBOARD INTERRUPTS: space q ? r c C l p m t T 0 1 2 3 4 5 e E P + -  F5..F9"
  490.         );
  491.     PRINT "\n");
  492.     PRINT
  493.         "cross KEYBOARD INTERRUPTS: %c%c%c%c b B C i I w s u x X y Y F1..F4 F10 k K O\n"
  494.         ,UPARROW, DNARROW, LTARROW, RTARROW);
  495.     scr_rowcol(0, 0);    /* move cursor to top left; */
  496. #endif    /* MAINFRAME */
  497. }
  498. /* -------------------------------------------------------------------- */
  499. /* DRAW_BOX - draw a box with x coordinates X_low,X_upp
  500.  * and y coordinates Y_low,Y_upp.
  501.  */
  502. draw_box()
  503. {
  504.     int    width, height;        /* of rectangle */
  505.     POINT    origin, *dest;
  506.     double  X_small,
  507.             Y_small;
  508.  
  509.     /*  set_box() sets X_low thru Y_upp; set_box ==
  510.      * 0 if box is partially outside window.
  511.      */
  512.     if(set_box() != 0 && ticFlag != OFF)
  513.         ticMarks(ticFlag);
  514.     PrintBoxCoordinates();        /* if printer > 1 */
  515.     Y_small = 0.00001 * (Y_upp - Y_low);
  516.     X_small = 0.00001 * (X_upp - X_low);
  517.     if((dest = FindPixel(X_low + X_small, Y_low + Y_small, SCRN)) != NULL) {
  518.         origin = *dest;
  519.         if((dest = FindPixel(X_upp - X_small, Y_upp - Y_small, SCRN))
  520.             != NULL)  {
  521.             width = dest->x - origin.x;
  522.             height = dest->y - origin.y;
  523.             XDrawRectangle(x_dpy, x_window, x_gc, origin.x, 
  524.                 origin.y, (unsigned) width, (unsigned) height);
  525.         }
  526.     }
  527.     stoplines();         /* for stopping drawing connected lines */
  528.     return;
  529. }
  530. /* -------------------------------------------------------------------- */
  531. PrintBoxCoordinates()     /* if printer > 1 */
  532. {
  533.     scr_rowcol(20, 0);
  534.     if(printer > 1) {
  535.         set_box();    /* sets X_low thru Y_upp */
  536.         erase_line();
  537.         PRINT
  538.             "box coords: LEFT: %g  RIGHT: %g  BOTTOM: %g  TOP: %g\n",
  539.             X_low, X_upp, Y_low, Y_upp);
  540.     }
  541.     return;
  542. }
  543. /* -------------------------------------------------------------------- */
  544. /* ERASE_LINE - in X windows, we don't worry about messing up the graphics
  545.  * screen, so just output a newline.
  546.  */
  547. erase_line() 
  548. {
  549.     PRINT "\n");
  550. }
  551. /* -------------------------------------------------------------------- */
  552. /* DEFINITELY_ERASE_LINE - likewise. */
  553. definitely_erase_line() 
  554. {
  555.     PRINT "\n");
  556. }
  557. /* -------------------------------------------------------------------- */
  558. /* MASKDEF - a no-op for now. */
  559. maskdef(MASK)
  560. char    MASK[];
  561. {
  562.     return;
  563. }
  564. /* -------------------------------------------------------------------- */
  565. /* TD - a dummy routine for now */
  566. td(junk) 
  567. char    *junk;
  568. {
  569.     PRINT "The TD option is not implemented yet on X windows\n");
  570.     return;
  571. }
  572. /* -------------------------------------------------------------------- */
  573. /* TD0 - a dummy routine for now */
  574. td0(junk) 
  575. char    *junk;
  576. {
  577.     PRINT "The TD0 option is not implemented yet on X windows\n");
  578.     return;
  579. }
  580. /* -------------------------------------------------------------------- */
  581. /* RESETDIAMETERS -  this routine resets the sets "diameters[ScrnSec]"
  582.  * when the screen is rescaled using 's' or 'u'; "diameters[ScrnSec]" is
  583.  * needed so that when the trajectory gets too far away from the region of
  584.  * interest, the process can be stopped; this prevents overflow; when
  585.  * changing the scale so that a small region can be examined, it is
  586.  * necessary to reset "diameters" to a correspondingly larger value.
  587.  */
  588. resetDiameters() 
  589. {
  590.     double  maximum,
  591.             Xratio,
  592.             Yratio;
  593.  
  594.     set_box();
  595.     Xratio = fabs((X_upp - X_low) / (X_upper - X_lower));
  596.     Yratio = fabs((Y_upp - Y_low) / (Y_upper - Y_lower));
  597.     maximum = max(1.0 / Xratio, 1.0);
  598.     if(1 / Yratio > maximum)
  599.         maximum = 1 / Yratio;
  600.  
  601.     /* diameters: Let d = diameters. Recall that the big window is d
  602.      * windows above and below the screen, so if the screen in one
  603.      * coordinate(Y) runs from -1 to 1, then the big window runs from -2*d-1
  604.      * to 2*d+1, while the new presumably smaller window runs from 
  605.      * -Yratio to + Yratio. The big window is (2*d +1)/Yratio times bigger 
  606.      * than the
  607.      * little window; if D is the new diameter, then that must be 2D+1 times
  608.      * the little window; hence D =
  609.      * .5*[(2*d + 1)/Yratio -1] = (d + .5)maximum -.5   If d < 0, we do not
  610.      * have to change it because negative values simply means we should 
  611.      * ignore it.
  612.      */
  613.     if(diameters[ScrnSec] >= 0)
  614.         diameters[ScrnSec] = maximum * (.5 + diameters[OldScrSec]) -.5;
  615.     return;
  616. }
  617. /* -------------------------------------------------------------------- */
  618. /* SET_BOX - set the for box edges X_low thru Y_upp to be x_new_low thru
  619.  * y_new_upp when they have been set(so they are not the default values);
  620.  * when they have not been set the current box edges are used: X_lower
  621.  * thru Y_upper; notice that no check is made of whether x_new_low is less
  622.  * than x_new_upp; these names are misleading since they really refer to
  623.  * left and right rather than which coordinate is less than another;
  624.  * returns: 1 if box is inside(or equal to) window 0 if outside.
  625.  */
  626. int     set_box()
  627. {        
  628.     X_low = x_new_low;
  629.     if(X_low == -9999)
  630.         X_low = X_lower;/* equals first argument unless it is -9999, in
  631.                    which case it equals the second argument */
  632.     X_upp = x_new_upp;
  633.     if(X_upp == -9999)
  634.         X_upp = X_upper;
  635.  
  636.     Y_low = y_new_low;
  637.     if(Y_low == -9999)
  638.         Y_low = Y_lower;
  639.  
  640.     Y_upp = y_new_upp;
  641.     if(Y_upp == -9999)
  642.         Y_upp = Y_upper;
  643.  
  644.      /* test location of box */
  645.     if((X_low - X_lower) * (X_upper - X_low) < 0
  646.             || (Y_low - Y_lower) * (Y_upper - Y_low) < 0
  647.             || (X_upp - X_lower) * (X_upper - X_upp) < 0
  648.             || (Y_upp - Y_lower) * (Y_upper - Y_upp) < 0) {
  649.         scr_rowcol(3, 0);
  650.         erase_line();
  651.         PRINT "Box is at least partially outside window\n");
  652.         return(0);
  653.     }
  654.     return(1);
  655. }
  656. /* -------------------------------------------------------------------- */
  657. /* PPRINT - dummy routine for handling printers for now.
  658.  */
  659. pprint(junk)
  660. int    junk;
  661. {
  662.     printf("Printing is not implemented yet under X windows\n");
  663.     return;
  664. }
  665. /* -------------------------------------------------------------------- */
  666. int checkPrinter()        /* dummy version for now */
  667. {
  668.     return(NO);
  669. }
  670. /* -------------------------------------------------------------------- */
  671. int printerStatus()        /* dummy version for now */
  672. {
  673.     return(NO);
  674. }
  675. #endif    /* X11 */
  676.